void main () {
  sum(1,2,isPrint: true);
  FunctionLearn functionLearn = FunctionLearn();
  functionLearn.sum(1,2,isPrint: true);
}

int sum (int num1, int num2, { bool? isPrint = false }) {
  var result = num1 + num2;
  if (isPrint ?? false) {
    print('result: $result');
  }
  return result;
}

class FunctionLearn {
  int sum (int num1, int num2, { bool? isPrint = false }) {
    var result = num1 + num2;
    if (isPrint ?? false) {
      print('result: $result');
    }
    return result;
  }
}